<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>手机端选项卡</title>
    <style>
      * {
        box-sizing: border-box;
      }

      body {
        background-color: rgba(155, 89, 182, 0.7);
        font-family: "Open Sans", sans-serif;
        display: flex;
        align-items: center;
        justify-content: center;
        height: 100vh;
        margin: 0;
      }

      .phone {
        position: relative;
        overflow: hidden;
        border: 3px solid #eee;
        border-radius: 15px;
        height: 600px;
        width: 340px;
      }

      .phone .content {
        opacity: 0;
        object-fit: cover;
        position: absolute;
        top: 0;
        left: 0;
        height: calc(100% - 60px);
        width: 100%;
        transition: opacity 0.4s ease;
      }

      .phone .content.show {
        opacity: 1;
      }

      nav {
        position: absolute;
        bottom: 0;
        left: 0;
        margin-top: -5px;
        width: 100%;
      }

      nav ul {
        background-color: #fff;
        display: flex;
        list-style-type: none;
        padding: 0;
        margin: 0;
        height: 60px;
      }

      nav li {
        color: #777;
        cursor: pointer;
        flex: 1;
        padding: 10px;
        text-align: center;
      }

      nav ul li p {
        font-size: 12px;
        margin: 2px 0;
      }

      nav ul li:hover,
      nav ul li.active {
        color: #8e44ad;
      }
      #san{
        width: 20px;
        height: 20px;
        background-color: #eee;
        position: relative;
        right: -360px;
        top: -278px;
      }
    </style>
  </head>
  <body>
    <button id="san">×</button>
    <div class="phone">
      <img src="./img/about.jpeg" alt="home" class="content show" id="x" />
      
      <nav>
        <ul>
          <li class="active">
            <i class="fas fa-home"></i>
            <p id="a">Home</p>
          </li>
          <li class="b">
            <i class="fas fa-box" ></i>
            <p >Work</p>
          </li>
          <li>
            <i class="fas fa-book-open"></i>
            <p class="c">Blog</p>
          </li>
          <li>
            <i class="fas fa-users"></i>
            <p class="d">About Us</p>
          </li>
        </ul>
      </nav>
    </div>
    <script>
    //获取元素
     var l1=document.getElementById("a")//按钮1
     var l2=document.querySelector(".b")//按钮2
     var l3=document.querySelector(".c")//按钮3
     var l4=document.querySelector(".d")//按钮4
     var tu=document.getElementById("x")//图
     var san=document.getElementById("san")
     var phone=document.querySelector(".phone")//x按钮
 
//注册事件，程序处理
  l1.addEventListener("click", function () {
      tu.src="./img/about.jpeg"
        });
  l2.onclick=function(){
   tu.src="./img/blog.jpeg"
  }
  l3.onclick=function(){
   tu.src="./img/home.jpeg"
  }
  l4.onclick=function(){
   tu.src="./img/work.jpeg"
  }
  san.onclick=function(){
    phone.style.display="none"
    san.style.display="none"//隐藏样式
  }
  
    </script>
  </body>
</html>
